stages:
  - build
  - upload
  - deploy

build:
  stage: build
  script:
    - docker build -t backend:$CI_COMMIT_SHORT_SHA ./backend
    - docker build -t frontend:$CI_COMMIT_SHORT_SHA ./frontend/my-app

upload:
  stage: upload
  script:
    - kind load docker-image backend:${CI_COMMIT_SHORT_SHA}
    - kind load docker-image frontend:${CI_COMMIT_SHORT_SHA}
  
deploy-test:
  stage: deploy
  environment:
    name: production
  script:
    - kubectl get pods --namespace=kube-system
    - kubectl apply -f manifests/frontend-deployment.yaml
    - kubectl apply -f manifests/backend-deployment.yaml
    - kubectl apply -f manifests/frontend-service.yaml
    - kubectl apply -f manifests/backend-service.yaml